﻿#ifndef			_XANADU_CORE_LOG_H_
#define			_XANADU_CORE_LOG_H_

#include <XanaduCore/XHeader.h>
#include <XanaduCore/XString.h>


// Xanadu log level
enum EXANADU_LOG_LEVEL
{
	kXANADU_LOG_LEVEL_FULL = 0,
	kXANADU_LOG_LEVEL_DEBUG,
	kXANADU_LOG_LEVEL_INFO,
	kXANADU_LOG_LEVEL_WARNING,
	kXANADU_LOG_LEVEL_ERROR,
	kXANADU_LOG_LEVEL_FATAL,
};

// Xanadu Class Log
class XANADU_CORE_EXPORT XLog
{
public:
	// constructor
	XLog() noexcept;

	// destructor
	virtual ~XLog() noexcept;

public:
	// Set the current log level, which is kXANADU_LOG_LEVEL_FULL by default
	static void setLogLevel(EXANADU_LOG_LEVEL _Level) noexcept;

public:
	// Outputs the log at the specified level
	static void output(EXANADU_LOG_LEVEL _Level, const char* _Format, ...) noexcept;

	// Outputs the log at the specified level
	static void output(EXANADU_LOG_LEVEL _Level, const XString& _Format) noexcept;
};

// Log convenient call macro
#define			XLOG_DEBUG(_Format, ...)				XLog::output(kXANADU_LOG_LEVEL_DEBUG, _Format, ##__VA_ARGS__)
#define			XLOG_INFO(_Format, ...)					XLog::output(kXANADU_LOG_LEVEL_INFO, _Format, ##__VA_ARGS__)
#define			XLOG_WARNING(_Format, ...)				XLog::output(kXANADU_LOG_LEVEL_WARNING, _Format, ##__VA_ARGS__)
#define			XLOG_ERROR(_Format, ...)				XLog::output(kXANADU_LOG_LEVEL_ERROR, _Format, ##__VA_ARGS__)
#define			XLOG_FATAL(_Format, ...)				XLog::output(kXANADU_LOG_LEVEL_FATAL, _Format, ##__VA_ARGS__)

#endif
